package org.example.controller;

import org.example.entity.Task;
import org.example.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TaskController {

    @Autowired
    private TaskService taskService;

    @PostMapping("/schedule")
    public void scheduleTask(@RequestParam String taskName) {
        taskService.scheduleTask(taskName);
    }

    @GetMapping("/taskByUuid")
    public Task getTaskByUuid(@RequestParam String taskUuid) {
        return taskService.getTaskByUuid(taskUuid);
    }

    @GetMapping("/allTasks")
    public List<Task> getAllTasks() {
        return taskService.getAllTasks();
    }
}
